package com.gx.smart.construction.ui.house.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.recyclerview.widget.RecyclerView;

import com.gx.smart.base.BaseAdapter;
import com.gx.smart.construction.R;
import com.gx.smart.construction.databinding.ItemRecordItemLayoutBinding;
import com.gx.wisestone.constructionappgrpclib.grpc.roominfo.ConstructionAppRoomInfo;

import javax.inject.Inject;

import dagger.hilt.android.qualifiers.ActivityContext;

/**
 * @author xiaosy
 * @create 2019-11-20
 * @Describe
 **/
public class RecordItemAdapter extends BaseAdapter<ConstructionAppRoomInfo, RecordItemAdapter.ViewHolder> {

    @Inject
    public RecordItemAdapter(@ActivityContext Context context) {
        super(context);
    }

    @Override
    protected int onBindLayout() {
        return R.layout.item_record_item_layout;
    }

    @Override
    protected ViewHolder onCreateHolder(View view) {
        ItemRecordItemLayoutBinding binding = ItemRecordItemLayoutBinding.inflate(LayoutInflater.from(mContext), (ViewGroup) view, false);
        return new ViewHolder(binding);
    }

    /**
     * string zone_name = 2;//分区名称
     * string building_name = 3;//楼栋名称
     * string unit_name = 4;//单元名称
     * string number = 5;//户室号码
     * string sn = 6;//网关编号
     *
     * @param holder
     * @param item
     * @param position
     */
    @Override
    protected void onBindData(ViewHolder holder, ConstructionAppRoomInfo item, int position) {
        holder.binding.setItem(item);
    }


    public class ViewHolder extends RecyclerView.ViewHolder {
        private ItemRecordItemLayoutBinding binding;

        ViewHolder(ItemRecordItemLayoutBinding binding) {
            super(binding.getRoot());
            this.binding = binding;
        }
    }
}
